{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>.container { width:100% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                                持买仓量\n",
      "date       variety 持买仓量期货公司         \n",
      "2018-10-08 A       中粮期货        763.0\n",
      "           AG      中粮期货       4050.0\n",
      "           AL      中粮期货      15496.0\n",
      "           BU      中粮期货       4358.0\n",
      "           C       中粮期货      54026.0\n",
      "                                持卖仓量\n",
      "date       variety 持卖仓量期货公司         \n",
      "2018-10-08 A       中粮期货       2643.0\n",
      "           AL      中粮期货      18253.0\n",
      "           AU      中粮期货        593.0\n",
      "           BU      中粮期货       8040.0\n",
      "           C       中粮期货      49654.0\n",
      "         date variety  会员简称     持买仓量     持卖仓量     净持仓\n",
      "0  2018-10-08       A  中粮期货    763.0   2643.0 -1880.0\n",
      "1  2018-10-08      AG  中粮期货   4050.0      0.0  4050.0\n",
      "2  2018-10-08      AL  中粮期货  15496.0  18253.0 -2757.0\n",
      "3  2018-10-08      BU  中粮期货   4358.0   8040.0 -3682.0\n",
      "4  2018-10-08       C  中粮期货  54026.0  49654.0  4372.0\n",
      "         date variety  contractValue\n",
      "0  2018-10-08      AG        52965.0\n",
      "1  2018-10-08      AL        72395.0\n",
      "2  2018-10-08      AP       117160.0\n",
      "3  2018-10-08      AU       269000.0\n",
      "4  2018-10-08      BU        37660.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>RU</th>\n",
       "      <th>MA</th>\n",
       "      <th>V</th>\n",
       "      <th>L</th>\n",
       "      <th>PP</th>\n",
       "      <th>BU</th>\n",
       "      <th>PTA</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>化工板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-08</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-546440500</td>\n",
       "      <td>0</td>\n",
       "      <td>-227373810</td>\n",
       "      <td>0</td>\n",
       "      <td>38953600</td>\n",
       "      <td>-138664120</td>\n",
       "      <td>-171458430</td>\n",
       "      <td>-71044615790</td>\n",
       "      <td>-5477522010</td>\n",
       "      <td>-1044983260</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-09</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-602125050</td>\n",
       "      <td>0</td>\n",
       "      <td>-232662000</td>\n",
       "      <td>-140993220</td>\n",
       "      <td>10245140</td>\n",
       "      <td>-152837440</td>\n",
       "      <td>-40563280</td>\n",
       "      <td>-76687351005</td>\n",
       "      <td>-5665513155</td>\n",
       "      <td>-1158935850</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-10</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-624699400</td>\n",
       "      <td>0</td>\n",
       "      <td>-91456305</td>\n",
       "      <td>-216275465</td>\n",
       "      <td>-27529640</td>\n",
       "      <td>-34739650</td>\n",
       "      <td>43456875</td>\n",
       "      <td>-78571501110</td>\n",
       "      <td>-5921287420</td>\n",
       "      <td>-951243585</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-11</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-579458880</td>\n",
       "      <td>0</td>\n",
       "      <td>-49541940</td>\n",
       "      <td>-194493285</td>\n",
       "      <td>-65945940</td>\n",
       "      <td>-70439160</td>\n",
       "      <td>280659280</td>\n",
       "      <td>-76653224215</td>\n",
       "      <td>-5683207065</td>\n",
       "      <td>-679219925</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-12</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-573701805</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-191917215</td>\n",
       "      <td>-75050430</td>\n",
       "      <td>-74107760</td>\n",
       "      <td>310544370</td>\n",
       "      <td>-74116812685</td>\n",
       "      <td>-4841636035</td>\n",
       "      <td>-604232840</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-15</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-560791225</td>\n",
       "      <td>0</td>\n",
       "      <td>-85019880</td>\n",
       "      <td>-146206315</td>\n",
       "      <td>-299395320</td>\n",
       "      <td>-67025300</td>\n",
       "      <td>394971610</td>\n",
       "      <td>-72862043073</td>\n",
       "      <td>-4913318191</td>\n",
       "      <td>-763466430</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-16</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-558753860</td>\n",
       "      <td>0</td>\n",
       "      <td>-99848060</td>\n",
       "      <td>-128613510</td>\n",
       "      <td>-389431810</td>\n",
       "      <td>-172420820</td>\n",
       "      <td>366955150</td>\n",
       "      <td>-70711991125</td>\n",
       "      <td>-4920329935</td>\n",
       "      <td>-982112910</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-17</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-558930700</td>\n",
       "      <td>0</td>\n",
       "      <td>-99612500</td>\n",
       "      <td>-124307745</td>\n",
       "      <td>-459659100</td>\n",
       "      <td>-62678480</td>\n",
       "      <td>328660345</td>\n",
       "      <td>-71195885948</td>\n",
       "      <td>-5196281486</td>\n",
       "      <td>-976528180</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-18</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-539262875</td>\n",
       "      <td>0</td>\n",
       "      <td>-162318245</td>\n",
       "      <td>-86886580</td>\n",
       "      <td>-519282000</td>\n",
       "      <td>-44699960</td>\n",
       "      <td>307195720</td>\n",
       "      <td>-69060480607</td>\n",
       "      <td>-4987150599</td>\n",
       "      <td>-1045253940</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-19</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-543997360</td>\n",
       "      <td>0</td>\n",
       "      <td>-199803560</td>\n",
       "      <td>-87937350</td>\n",
       "      <td>-492950120</td>\n",
       "      <td>-161163400</td>\n",
       "      <td>335851140</td>\n",
       "      <td>-71437517578</td>\n",
       "      <td>-5439907186</td>\n",
       "      <td>-1150000650</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-539891985</td>\n",
       "      <td>0</td>\n",
       "      <td>-115833815</td>\n",
       "      <td>-94586840</td>\n",
       "      <td>-561486690</td>\n",
       "      <td>-166046650</td>\n",
       "      <td>384490300</td>\n",
       "      <td>-69276562220</td>\n",
       "      <td>-5176415720</td>\n",
       "      <td>-1093355680</td>\n",
       "      <td>PTA</td>\n",
       "      <td>PP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-548387775</td>\n",
       "      <td>-286335280</td>\n",
       "      <td>-47828895</td>\n",
       "      <td>-93322140</td>\n",
       "      <td>-495399060</td>\n",
       "      <td>-164049270</td>\n",
       "      <td>478478300</td>\n",
       "      <td>-73368642701</td>\n",
       "      <td>-6631575517</td>\n",
       "      <td>-1156844120</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-570394880</td>\n",
       "      <td>0</td>\n",
       "      <td>-48536250</td>\n",
       "      <td>-93810510</td>\n",
       "      <td>-453541350</td>\n",
       "      <td>-163939950</td>\n",
       "      <td>570540175</td>\n",
       "      <td>-69645690044</td>\n",
       "      <td>-5917231358</td>\n",
       "      <td>-759682765</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-571405500</td>\n",
       "      <td>-337369290</td>\n",
       "      <td>-124340460</td>\n",
       "      <td>-106532780</td>\n",
       "      <td>-450060600</td>\n",
       "      <td>-147907690</td>\n",
       "      <td>496941110</td>\n",
       "      <td>-69291507082</td>\n",
       "      <td>-6331086834</td>\n",
       "      <td>-1240675210</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-561628125</td>\n",
       "      <td>-380119780</td>\n",
       "      <td>-64224425</td>\n",
       "      <td>-154475000</td>\n",
       "      <td>-417620300</td>\n",
       "      <td>-145447920</td>\n",
       "      <td>396845800</td>\n",
       "      <td>-70775573636</td>\n",
       "      <td>-6784736202</td>\n",
       "      <td>-1326669750</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-522378625</td>\n",
       "      <td>-472728660</td>\n",
       "      <td>0</td>\n",
       "      <td>-143279655</td>\n",
       "      <td>-425264505</td>\n",
       "      <td>-149617620</td>\n",
       "      <td>610082825</td>\n",
       "      <td>-69205142171</td>\n",
       "      <td>-6730111117</td>\n",
       "      <td>-1103186240</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-525996000</td>\n",
       "      <td>-397597440</td>\n",
       "      <td>0</td>\n",
       "      <td>-140958040</td>\n",
       "      <td>-350420050</td>\n",
       "      <td>-150105620</td>\n",
       "      <td>975141090</td>\n",
       "      <td>-64856961559</td>\n",
       "      <td>-5998168873</td>\n",
       "      <td>-589936060</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-536143880</td>\n",
       "      <td>-431481240</td>\n",
       "      <td>-47071420</td>\n",
       "      <td>-166724330</td>\n",
       "      <td>-343755100</td>\n",
       "      <td>-155495860</td>\n",
       "      <td>916329645</td>\n",
       "      <td>-63843781853</td>\n",
       "      <td>-6132398631</td>\n",
       "      <td>-764342185</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-533049715</td>\n",
       "      <td>-396488430</td>\n",
       "      <td>-118570995</td>\n",
       "      <td>-73657680</td>\n",
       "      <td>-324049950</td>\n",
       "      <td>-123090900</td>\n",
       "      <td>982401560</td>\n",
       "      <td>-61308174591</td>\n",
       "      <td>-6114469357</td>\n",
       "      <td>-586506110</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-540851200</td>\n",
       "      <td>-379389000</td>\n",
       "      <td>-114152735</td>\n",
       "      <td>-138114570</td>\n",
       "      <td>-330789620</td>\n",
       "      <td>-134828560</td>\n",
       "      <td>975912750</td>\n",
       "      <td>-57379308013</td>\n",
       "      <td>-5786287321</td>\n",
       "      <td>-662212935</td>\n",
       "      <td>PTA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                 RU         MA          V          L         PP  \\\n",
       "date       会员简称                                                          \n",
       "2018-10-08 中粮期货 -546440500          0 -227373810          0   38953600   \n",
       "2018-10-09 中粮期货 -602125050          0 -232662000 -140993220   10245140   \n",
       "2018-10-10 中粮期货 -624699400          0  -91456305 -216275465  -27529640   \n",
       "2018-10-11 中粮期货 -579458880          0  -49541940 -194493285  -65945940   \n",
       "2018-10-12 中粮期货 -573701805          0          0 -191917215  -75050430   \n",
       "2018-10-15 中粮期货 -560791225          0  -85019880 -146206315 -299395320   \n",
       "2018-10-16 中粮期货 -558753860          0  -99848060 -128613510 -389431810   \n",
       "2018-10-17 中粮期货 -558930700          0  -99612500 -124307745 -459659100   \n",
       "2018-10-18 中粮期货 -539262875          0 -162318245  -86886580 -519282000   \n",
       "2018-10-19 中粮期货 -543997360          0 -199803560  -87937350 -492950120   \n",
       "2018-10-22 中粮期货 -539891985          0 -115833815  -94586840 -561486690   \n",
       "2018-10-23 中粮期货 -548387775 -286335280  -47828895  -93322140 -495399060   \n",
       "2018-10-24 中粮期货 -570394880          0  -48536250  -93810510 -453541350   \n",
       "2018-10-25 中粮期货 -571405500 -337369290 -124340460 -106532780 -450060600   \n",
       "2018-10-26 中粮期货 -561628125 -380119780  -64224425 -154475000 -417620300   \n",
       "2018-10-29 中粮期货 -522378625 -472728660          0 -143279655 -425264505   \n",
       "2018-10-30 中粮期货 -525996000 -397597440          0 -140958040 -350420050   \n",
       "2018-10-31 中粮期货 -536143880 -431481240  -47071420 -166724330 -343755100   \n",
       "2018-11-01 中粮期货 -533049715 -396488430 -118570995  -73657680 -324049950   \n",
       "2018-11-02 中粮期货 -540851200 -379389000 -114152735 -138114570 -330789620   \n",
       "\n",
       "variety                 BU        PTA         商品板块         工业品        化工板块  \\\n",
       "date       会员简称                                                              \n",
       "2018-10-08 中粮期货 -138664120 -171458430 -71044615790 -5477522010 -1044983260   \n",
       "2018-10-09 中粮期货 -152837440  -40563280 -76687351005 -5665513155 -1158935850   \n",
       "2018-10-10 中粮期货  -34739650   43456875 -78571501110 -5921287420  -951243585   \n",
       "2018-10-11 中粮期货  -70439160  280659280 -76653224215 -5683207065  -679219925   \n",
       "2018-10-12 中粮期货  -74107760  310544370 -74116812685 -4841636035  -604232840   \n",
       "2018-10-15 中粮期货  -67025300  394971610 -72862043073 -4913318191  -763466430   \n",
       "2018-10-16 中粮期货 -172420820  366955150 -70711991125 -4920329935  -982112910   \n",
       "2018-10-17 中粮期货  -62678480  328660345 -71195885948 -5196281486  -976528180   \n",
       "2018-10-18 中粮期货  -44699960  307195720 -69060480607 -4987150599 -1045253940   \n",
       "2018-10-19 中粮期货 -161163400  335851140 -71437517578 -5439907186 -1150000650   \n",
       "2018-10-22 中粮期货 -166046650  384490300 -69276562220 -5176415720 -1093355680   \n",
       "2018-10-23 中粮期货 -164049270  478478300 -73368642701 -6631575517 -1156844120   \n",
       "2018-10-24 中粮期货 -163939950  570540175 -69645690044 -5917231358  -759682765   \n",
       "2018-10-25 中粮期货 -147907690  496941110 -69291507082 -6331086834 -1240675210   \n",
       "2018-10-26 中粮期货 -145447920  396845800 -70775573636 -6784736202 -1326669750   \n",
       "2018-10-29 中粮期货 -149617620  610082825 -69205142171 -6730111117 -1103186240   \n",
       "2018-10-30 中粮期货 -150105620  975141090 -64856961559 -5998168873  -589936060   \n",
       "2018-10-31 中粮期货 -155495860  916329645 -63843781853 -6132398631  -764342185   \n",
       "2018-11-01 中粮期货 -123090900  982401560 -61308174591 -6114469357  -586506110   \n",
       "2018-11-02 中粮期货 -134828560  975912750 -57379308013 -5786287321  -662212935   \n",
       "\n",
       "variety          max min  \n",
       "date       会员简称           \n",
       "2018-10-08 中粮期货   PP  RU  \n",
       "2018-10-09 中粮期货   PP  RU  \n",
       "2018-10-10 中粮期货  PTA  RU  \n",
       "2018-10-11 中粮期货  PTA  RU  \n",
       "2018-10-12 中粮期货  PTA  RU  \n",
       "2018-10-15 中粮期货  PTA  RU  \n",
       "2018-10-16 中粮期货  PTA  RU  \n",
       "2018-10-17 中粮期货  PTA  RU  \n",
       "2018-10-18 中粮期货  PTA  RU  \n",
       "2018-10-19 中粮期货  PTA  RU  \n",
       "2018-10-22 中粮期货  PTA  PP  \n",
       "2018-10-23 中粮期货  PTA  RU  \n",
       "2018-10-24 中粮期货  PTA  RU  \n",
       "2018-10-25 中粮期货  PTA  RU  \n",
       "2018-10-26 中粮期货  PTA  RU  \n",
       "2018-10-29 中粮期货  PTA  RU  \n",
       "2018-10-30 中粮期货  PTA  RU  \n",
       "2018-10-31 中粮期货  PTA  RU  \n",
       "2018-11-01 中粮期货  PTA  RU  \n",
       "2018-11-02 中粮期货  PTA  RU  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pymongo\n",
    "import pandas as pd\n",
    "import matplotlib as plt\n",
    "from pandas import Series,DataFrame\n",
    "pd.set_option('display.width', None)  # 设置字符显示宽度\n",
    "pd.set_option('display.max_rows', None)  # 设置显示最大行\n",
    "pd.set_option('display.max_columns', None)  # 设置显示最大行\n",
    "#二行即可搞定画图中文乱码\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "plt.rcParams['axes.unicode_minus']=False #用来正常显示负号\n",
    "from IPython.core.display import display, HTML\n",
    "display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
    "\n",
    "#连接数据库\n",
    "client = pymongo.MongoClient('localhost',27017)\n",
    "futures = client.futures\n",
    "\n",
    "market = futures.market\n",
    "unit = futures.unit\n",
    "position = futures.position\n",
    "\n",
    "#加载数据\n",
    "market = DataFrame(list(market.find()))\n",
    "unit = DataFrame(list(unit.find()))\n",
    "position = DataFrame(list(position.find()))\n",
    "\n",
    "#大写字母\n",
    "position['variety']=position['variety'].str.upper()\n",
    "\n",
    "#删除/选取某行含有特殊数值的列\n",
    "position=position.set_index('名次')\n",
    "\n",
    "#选择需要显示的字段\n",
    "data1=market[['date','variety','set_close']]\n",
    "\n",
    "data2=unit[[ 'variety','unit']]\n",
    "position=position[['date','variety','symbol','持买仓量期货公司','持买仓量', '持买仓量增减','持卖仓量期货公司','持卖仓量', '持卖仓量增减']]\n",
    "\n",
    "#查询会员\n",
    "members='中粮期货'\n",
    "data3=position[(position['持买仓量期货公司'] == members)]\n",
    "#汇总合约\n",
    "data3=data3[['date','variety','持买仓量期货公司','持买仓量']]\n",
    "data3=data3.groupby(['date','variety','持买仓量期货公司'])[['持买仓量']].sum()\n",
    "data4=position[(position['持卖仓量期货公司'] == members)]\n",
    "data4=data4[['date','variety','持卖仓量期货公司','持卖仓量']]\n",
    "data4=data4.groupby(['date','variety','持卖仓量期货公司'])[['持卖仓量']].sum()\n",
    "print(data3.head())\n",
    "print(data4.head())\n",
    "\n",
    "#并集\n",
    "data5=pd.merge(data3,data4, on=['date','variety'],how='outer')\n",
    "data5['会员简称']=data5.apply(lambda x: members,axis=1)\n",
    "\n",
    "#nan缺失值填充fillna()为0\n",
    "data5=data5.fillna(0)\n",
    "data5['净持仓']=data5.apply(lambda x: x['持买仓量']-x['持卖仓量'],axis=1)\n",
    "#选择需要显示的字段\n",
    "data5=data5[['会员简称','持买仓量','持卖仓量','净持仓']]\n",
    "data5=data5.reset_index(['variety','date'])\n",
    "print(data5.head())\n",
    "netpostion=data5.set_index('date')\n",
    "\n",
    "netpostion=data5.pivot_table('净持仓',index='date',columns='variety',fill_value=0)\n",
    "\n",
    "#合约价值\n",
    "contractValue=pd.merge(data1,data2,how='left',sort=False).drop_duplicates()\n",
    "contractValue['contractValue'] = contractValue.apply(lambda x: x['set_close']*x['unit'],axis=1)\n",
    "contractValue=contractValue[['date','variety','contractValue']]\n",
    "#值替换replace()\n",
    "contractValue=contractValue.replace(['TA'],'PTA')\n",
    "print(contractValue.head())\n",
    "sz=pd.merge(data5,contractValue,on=['date','variety'],how='left')\n",
    "\n",
    "#净持仓价值\n",
    "sz['净持仓价值']=sz.apply(lambda x: x['净持仓']*x['contractValue'],axis=1)\n",
    "sz=sz[['date','variety','会员简称','净持仓价值']]\n",
    "sz=sz.sort_values(by='净持仓价值')\n",
    "sz=sz.pivot_table('净持仓价值',index=['date','会员简称'],columns='variety',fill_value=0)\n",
    "sz=sz.copy()\n",
    "\n",
    "sz['化工板块']=sz[['RU','MA','V','L','PP','BU','PTA']].sum(axis=1)\n",
    "sz['油脂板块']=sz[['Y','P','OI']].sum(axis=1)\n",
    "sz['有色板块']=sz[['CU','AL','ZN','NI','PB']].sum(axis=1)\n",
    "sz['黑色板块']=sz[['RB','HC','J','JM','I']].sum(axis=1)\n",
    "sz['黄金白银']=sz[['AU','AG']].sum(axis=1)\n",
    "sz['工业品']=sz[['CU','AL','ZN','NI','PB','RB','FG','RU','L','V','PTA','MA','PP','JM','J','I','BU','HC','FU']].sum(axis=1)#ZC\n",
    "sz['农产品']=sz[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].sum(axis=1)\n",
    "sz['商品板块']=sz.sum(axis=1)\n",
    "sz\n",
    "\n",
    "\n",
    "chemical=sz.copy()\n",
    "chemical=chemical[['RU','MA','V','L','PP','BU','PTA','商品板块','工业品','化工板块']]\n",
    "chemical['max']=chemical[['RU','MA','V','L','PP','BU','PTA']].idxmax(axis=1)\n",
    "chemical['min']=chemical[['RU','MA','V','L','PP','BU']].idxmin(axis=1)\n",
    "chemical\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>RB</th>\n",
       "      <th>HC</th>\n",
       "      <th>J</th>\n",
       "      <th>JM</th>\n",
       "      <th>I</th>\n",
       "      <th>黑色板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-08</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-857700360</td>\n",
       "      <td>3491100</td>\n",
       "      <td>-623042000</td>\n",
       "      <td>185395500</td>\n",
       "      <td>197604000</td>\n",
       "      <td>-1094251760</td>\n",
       "      <td>-5477522010</td>\n",
       "      <td>-71044615790</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-09</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-740564400</td>\n",
       "      <td>3537900</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>271856900</td>\n",
       "      <td>-465169600</td>\n",
       "      <td>-5665513155</td>\n",
       "      <td>-76687351005</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-10</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-859542330</td>\n",
       "      <td>3538800</td>\n",
       "      <td>0</td>\n",
       "      <td>-165156120</td>\n",
       "      <td>296485500</td>\n",
       "      <td>-724674150</td>\n",
       "      <td>-5921287420</td>\n",
       "      <td>-78571501110</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-11</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-687155070</td>\n",
       "      <td>3504600</td>\n",
       "      <td>0</td>\n",
       "      <td>-193365900</td>\n",
       "      <td>283750400</td>\n",
       "      <td>-593265970</td>\n",
       "      <td>-5683207065</td>\n",
       "      <td>-76653224215</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-12</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-190956840</td>\n",
       "      <td>349383600</td>\n",
       "      <td>158426760</td>\n",
       "      <td>-4841636035</td>\n",
       "      <td>-74116812685</td>\n",
       "      <td>I</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-15</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-324328800</td>\n",
       "      <td>358581000</td>\n",
       "      <td>34252200</td>\n",
       "      <td>-4913318191</td>\n",
       "      <td>-72862043073</td>\n",
       "      <td>I</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-16</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-338003040</td>\n",
       "      <td>82916100</td>\n",
       "      <td>-255086940</td>\n",
       "      <td>-4920329935</td>\n",
       "      <td>-70711991125</td>\n",
       "      <td>I</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-17</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-321092640</td>\n",
       "      <td>44455000</td>\n",
       "      <td>-276637640</td>\n",
       "      <td>-5196281486</td>\n",
       "      <td>-71195885948</td>\n",
       "      <td>I</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-18</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-74079180</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-322543260</td>\n",
       "      <td>-37689300</td>\n",
       "      <td>-434311740</td>\n",
       "      <td>-4987150599</td>\n",
       "      <td>-69060480607</td>\n",
       "      <td>HC</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-19</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-158979000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-300728700</td>\n",
       "      <td>-62791200</td>\n",
       "      <td>-522498900</td>\n",
       "      <td>-5439907186</td>\n",
       "      <td>-71437517578</td>\n",
       "      <td>HC</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>10125850</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-385152000</td>\n",
       "      <td>-8069600</td>\n",
       "      <td>-383095750</td>\n",
       "      <td>-5176415720</td>\n",
       "      <td>-69276562220</td>\n",
       "      <td>RB</td>\n",
       "      <td>JM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-954737640</td>\n",
       "      <td>0</td>\n",
       "      <td>-629402400</td>\n",
       "      <td>-267941520</td>\n",
       "      <td>46450500</td>\n",
       "      <td>-1805631060</td>\n",
       "      <td>-6631575517</td>\n",
       "      <td>-73368642701</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-919340450</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-30339540</td>\n",
       "      <td>-427358000</td>\n",
       "      <td>-1377037990</td>\n",
       "      <td>-5917231358</td>\n",
       "      <td>-69645690044</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-927031320</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-282402180</td>\n",
       "      <td>-427940800</td>\n",
       "      <td>-1637374300</td>\n",
       "      <td>-6331086834</td>\n",
       "      <td>-69291507082</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1062014040</td>\n",
       "      <td>0</td>\n",
       "      <td>-676652000</td>\n",
       "      <td>-297496080</td>\n",
       "      <td>-48544800</td>\n",
       "      <td>-2084706920</td>\n",
       "      <td>-6784736202</td>\n",
       "      <td>-70775573636</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1005080260</td>\n",
       "      <td>0</td>\n",
       "      <td>-652384000</td>\n",
       "      <td>-298128600</td>\n",
       "      <td>-471700800</td>\n",
       "      <td>-2427293660</td>\n",
       "      <td>-6730111117</td>\n",
       "      <td>-69205142171</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-912552200</td>\n",
       "      <td>0</td>\n",
       "      <td>-647969900</td>\n",
       "      <td>-336335040</td>\n",
       "      <td>-543487600</td>\n",
       "      <td>-2440344740</td>\n",
       "      <td>-5998168873</td>\n",
       "      <td>-64856961559</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-985302000</td>\n",
       "      <td>0</td>\n",
       "      <td>-753032000</td>\n",
       "      <td>-291733200</td>\n",
       "      <td>-485503200</td>\n",
       "      <td>-2515570400</td>\n",
       "      <td>-6132398631</td>\n",
       "      <td>-63843781853</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1099307000</td>\n",
       "      <td>0</td>\n",
       "      <td>-732808700</td>\n",
       "      <td>-419160600</td>\n",
       "      <td>-778395200</td>\n",
       "      <td>-3029671500</td>\n",
       "      <td>-6114469357</td>\n",
       "      <td>-61308174591</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1040724360</td>\n",
       "      <td>0</td>\n",
       "      <td>-729182000</td>\n",
       "      <td>-185445300</td>\n",
       "      <td>-599610000</td>\n",
       "      <td>-2554961660</td>\n",
       "      <td>-5786287321</td>\n",
       "      <td>-57379308013</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                  RB       HC          J         JM          I  \\\n",
       "date       会员简称                                                         \n",
       "2018-10-08 中粮期货  -857700360  3491100 -623042000  185395500  197604000   \n",
       "2018-10-09 中粮期货  -740564400  3537900          0          0  271856900   \n",
       "2018-10-10 中粮期货  -859542330  3538800          0 -165156120  296485500   \n",
       "2018-10-11 中粮期货  -687155070  3504600          0 -193365900  283750400   \n",
       "2018-10-12 中粮期货           0        0          0 -190956840  349383600   \n",
       "2018-10-15 中粮期货           0        0          0 -324328800  358581000   \n",
       "2018-10-16 中粮期货           0        0          0 -338003040   82916100   \n",
       "2018-10-17 中粮期货           0        0          0 -321092640   44455000   \n",
       "2018-10-18 中粮期货   -74079180        0          0 -322543260  -37689300   \n",
       "2018-10-19 中粮期货  -158979000        0          0 -300728700  -62791200   \n",
       "2018-10-22 中粮期货    10125850        0          0 -385152000   -8069600   \n",
       "2018-10-23 中粮期货  -954737640        0 -629402400 -267941520   46450500   \n",
       "2018-10-24 中粮期货  -919340450        0          0  -30339540 -427358000   \n",
       "2018-10-25 中粮期货  -927031320        0          0 -282402180 -427940800   \n",
       "2018-10-26 中粮期货 -1062014040        0 -676652000 -297496080  -48544800   \n",
       "2018-10-29 中粮期货 -1005080260        0 -652384000 -298128600 -471700800   \n",
       "2018-10-30 中粮期货  -912552200        0 -647969900 -336335040 -543487600   \n",
       "2018-10-31 中粮期货  -985302000        0 -753032000 -291733200 -485503200   \n",
       "2018-11-01 中粮期货 -1099307000        0 -732808700 -419160600 -778395200   \n",
       "2018-11-02 中粮期货 -1040724360        0 -729182000 -185445300 -599610000   \n",
       "\n",
       "variety                黑色板块         工业品         商品板块 max min  \n",
       "date       会员简称                                               \n",
       "2018-10-08 中粮期货 -1094251760 -5477522010 -71044615790   I  RB  \n",
       "2018-10-09 中粮期货  -465169600 -5665513155 -76687351005   I  RB  \n",
       "2018-10-10 中粮期货  -724674150 -5921287420 -78571501110   I  RB  \n",
       "2018-10-11 中粮期货  -593265970 -5683207065 -76653224215   I  RB  \n",
       "2018-10-12 中粮期货   158426760 -4841636035 -74116812685   I  JM  \n",
       "2018-10-15 中粮期货    34252200 -4913318191 -72862043073   I  JM  \n",
       "2018-10-16 中粮期货  -255086940 -4920329935 -70711991125   I  JM  \n",
       "2018-10-17 中粮期货  -276637640 -5196281486 -71195885948   I  JM  \n",
       "2018-10-18 中粮期货  -434311740 -4987150599 -69060480607  HC  JM  \n",
       "2018-10-19 中粮期货  -522498900 -5439907186 -71437517578  HC  JM  \n",
       "2018-10-22 中粮期货  -383095750 -5176415720 -69276562220  RB  JM  \n",
       "2018-10-23 中粮期货 -1805631060 -6631575517 -73368642701   I  RB  \n",
       "2018-10-24 中粮期货 -1377037990 -5917231358 -69645690044  HC  RB  \n",
       "2018-10-25 中粮期货 -1637374300 -6331086834 -69291507082  HC  RB  \n",
       "2018-10-26 中粮期货 -2084706920 -6784736202 -70775573636  HC  RB  \n",
       "2018-10-29 中粮期货 -2427293660 -6730111117 -69205142171  HC  RB  \n",
       "2018-10-30 中粮期货 -2440344740 -5998168873 -64856961559  HC  RB  \n",
       "2018-10-31 中粮期货 -2515570400 -6132398631 -63843781853  HC  RB  \n",
       "2018-11-01 中粮期货 -3029671500 -6114469357 -61308174591  HC  RB  \n",
       "2018-11-02 中粮期货 -2554961660 -5786287321 -57379308013  HC  RB  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "黑色板块=sz.copy()\n",
    "黑色板块=黑色板块[['RB','HC','J','JM','I','黑色板块','工业品','商品板块']] \n",
    "黑色板块['max']=黑色板块[['RB','HC','J','JM','I']].idxmax(axis=1) \n",
    "黑色板块['min']=黑色板块[['RB','HC','J','JM','I']].idxmin(axis=1)\n",
    "黑色板块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>Y</th>\n",
       "      <th>P</th>\n",
       "      <th>OI</th>\n",
       "      <th>油脂板块</th>\n",
       "      <th>农产品</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5943453090</td>\n",
       "      <td>-758963520</td>\n",
       "      <td>-2052467060</td>\n",
       "      <td>-8754883670</td>\n",
       "      <td>-22564072605</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5908436730</td>\n",
       "      <td>-790305750</td>\n",
       "      <td>-1996948080</td>\n",
       "      <td>-8695690560</td>\n",
       "      <td>-22536963625</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5577101200</td>\n",
       "      <td>-685301790</td>\n",
       "      <td>-1843272800</td>\n",
       "      <td>-8105675790</td>\n",
       "      <td>-22045073530</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5374232960</td>\n",
       "      <td>-862337280</td>\n",
       "      <td>-1757536500</td>\n",
       "      <td>-7994106740</td>\n",
       "      <td>-21283744840</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5312536810</td>\n",
       "      <td>-1034237620</td>\n",
       "      <td>-1597992000</td>\n",
       "      <td>-7944766430</td>\n",
       "      <td>-21407938400</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5374043100</td>\n",
       "      <td>-974394480</td>\n",
       "      <td>-1642553280</td>\n",
       "      <td>-7990990860</td>\n",
       "      <td>-20676009510</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5360676200</td>\n",
       "      <td>-913192380</td>\n",
       "      <td>-1652571600</td>\n",
       "      <td>-7926440180</td>\n",
       "      <td>-19634834450</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-5045313520</td>\n",
       "      <td>-912230810</td>\n",
       "      <td>-1640930320</td>\n",
       "      <td>-7598474650</td>\n",
       "      <td>-19239356285</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-4998007080</td>\n",
       "      <td>-931916960</td>\n",
       "      <td>-1624006920</td>\n",
       "      <td>-7553930960</td>\n",
       "      <td>-18151894080</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-4442643560</td>\n",
       "      <td>-900821200</td>\n",
       "      <td>-1494827270</td>\n",
       "      <td>-6838292030</td>\n",
       "      <td>-16996755910</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                   Y           P          OI        油脂板块          农产品  \\\n",
       "date       会员简称                                                                \n",
       "2018-10-22 中粮期货 -5943453090  -758963520 -2052467060 -8754883670 -22564072605   \n",
       "2018-10-23 中粮期货 -5908436730  -790305750 -1996948080 -8695690560 -22536963625   \n",
       "2018-10-24 中粮期货 -5577101200  -685301790 -1843272800 -8105675790 -22045073530   \n",
       "2018-10-25 中粮期货 -5374232960  -862337280 -1757536500 -7994106740 -21283744840   \n",
       "2018-10-26 中粮期货 -5312536810 -1034237620 -1597992000 -7944766430 -21407938400   \n",
       "2018-10-29 中粮期货 -5374043100  -974394480 -1642553280 -7990990860 -20676009510   \n",
       "2018-10-30 中粮期货 -5360676200  -913192380 -1652571600 -7926440180 -19634834450   \n",
       "2018-10-31 中粮期货 -5045313520  -912230810 -1640930320 -7598474650 -19239356285   \n",
       "2018-11-01 中粮期货 -4998007080  -931916960 -1624006920 -7553930960 -18151894080   \n",
       "2018-11-02 中粮期货 -4442643560  -900821200 -1494827270 -6838292030 -16996755910   \n",
       "\n",
       "variety         max min  \n",
       "date       会员简称          \n",
       "2018-10-22 中粮期货   P   Y  \n",
       "2018-10-23 中粮期货   P   Y  \n",
       "2018-10-24 中粮期货   P   Y  \n",
       "2018-10-25 中粮期货   P   Y  \n",
       "2018-10-26 中粮期货   P   Y  \n",
       "2018-10-29 中粮期货   P   Y  \n",
       "2018-10-30 中粮期货   P   Y  \n",
       "2018-10-31 中粮期货   P   Y  \n",
       "2018-11-01 中粮期货   P   Y  \n",
       "2018-11-02 中粮期货   P   Y  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "oil=sz.copy()\n",
    "oil=oil[['Y','P','OI','油脂板块','农产品']]\n",
    "oil['max']=oil[['Y','P','OI']].idxmax(axis=1) \n",
    "oil['min']=oil[['Y','P','OI']].idxmin(axis=1)\n",
    "oil['2018-10-21':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>CU</th>\n",
       "      <th>AL</th>\n",
       "      <th>ZN</th>\n",
       "      <th>NI</th>\n",
       "      <th>PB</th>\n",
       "      <th>有色板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-08</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1883887680</td>\n",
       "      <td>-199593015</td>\n",
       "      <td>-449287560</td>\n",
       "      <td>-760855860</td>\n",
       "      <td>7669125</td>\n",
       "      <td>-3285954990</td>\n",
       "      <td>-5477522010</td>\n",
       "      <td>-71044615790</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-09</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2021899060</td>\n",
       "      <td>-167662365</td>\n",
       "      <td>-1059156000</td>\n",
       "      <td>-737042165</td>\n",
       "      <td>33713685</td>\n",
       "      <td>-3952045905</td>\n",
       "      <td>-5665513155</td>\n",
       "      <td>-76687351005</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-10</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2125892930</td>\n",
       "      <td>-223968095</td>\n",
       "      <td>-1355685090</td>\n",
       "      <td>-490269970</td>\n",
       "      <td>33540500</td>\n",
       "      <td>-4162275585</td>\n",
       "      <td>-5921287420</td>\n",
       "      <td>-78571501110</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-11</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2230454720</td>\n",
       "      <td>-132418560</td>\n",
       "      <td>-1450356390</td>\n",
       "      <td>-613586480</td>\n",
       "      <td>72163140</td>\n",
       "      <td>-4354653010</td>\n",
       "      <td>-5683207065</td>\n",
       "      <td>-76653224215</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-12</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2255304500</td>\n",
       "      <td>-158495060</td>\n",
       "      <td>-1553612500</td>\n",
       "      <td>-638110585</td>\n",
       "      <td>218937810</td>\n",
       "      <td>-4386584835</td>\n",
       "      <td>-4841636035</td>\n",
       "      <td>-74116812685</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-15</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2145604505</td>\n",
       "      <td>-141344690</td>\n",
       "      <td>-1532937040</td>\n",
       "      <td>-532164926</td>\n",
       "      <td>185444480</td>\n",
       "      <td>-4166606681</td>\n",
       "      <td>-4913318191</td>\n",
       "      <td>-72862043073</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-16</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2043577025</td>\n",
       "      <td>-10475220</td>\n",
       "      <td>-1215159920</td>\n",
       "      <td>-568863900</td>\n",
       "      <td>184583660</td>\n",
       "      <td>-3653492405</td>\n",
       "      <td>-4920329935</td>\n",
       "      <td>-70711991125</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-17</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2052721360</td>\n",
       "      <td>-48122865</td>\n",
       "      <td>-1459126305</td>\n",
       "      <td>-546658416</td>\n",
       "      <td>183929600</td>\n",
       "      <td>-3922699346</td>\n",
       "      <td>-5196281486</td>\n",
       "      <td>-71195885948</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-18</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2066710620</td>\n",
       "      <td>271584000</td>\n",
       "      <td>-1401753750</td>\n",
       "      <td>-472309734</td>\n",
       "      <td>181913655</td>\n",
       "      <td>-3487276449</td>\n",
       "      <td>-4987150599</td>\n",
       "      <td>-69060480607</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-19</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2163462880</td>\n",
       "      <td>226911285</td>\n",
       "      <td>-1490882705</td>\n",
       "      <td>-529672056</td>\n",
       "      <td>212298200</td>\n",
       "      <td>-3744808156</td>\n",
       "      <td>-5439907186</td>\n",
       "      <td>-71437517578</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2204748000</td>\n",
       "      <td>334010470</td>\n",
       "      <td>-1538727300</td>\n",
       "      <td>-506075490</td>\n",
       "      <td>196760850</td>\n",
       "      <td>-3718779470</td>\n",
       "      <td>-5176415720</td>\n",
       "      <td>-69276562220</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2210414085</td>\n",
       "      <td>317452670</td>\n",
       "      <td>-1377154695</td>\n",
       "      <td>-497496132</td>\n",
       "      <td>122152565</td>\n",
       "      <td>-3645459677</td>\n",
       "      <td>-6631575517</td>\n",
       "      <td>-73368642701</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2199454125</td>\n",
       "      <td>294166275</td>\n",
       "      <td>-1329446160</td>\n",
       "      <td>-527107698</td>\n",
       "      <td>13908465</td>\n",
       "      <td>-3747933243</td>\n",
       "      <td>-5917231358</td>\n",
       "      <td>-69645690044</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2056621275</td>\n",
       "      <td>385550880</td>\n",
       "      <td>-1207138485</td>\n",
       "      <td>-572711229</td>\n",
       "      <td>13912385</td>\n",
       "      <td>-3437007724</td>\n",
       "      <td>-6331086834</td>\n",
       "      <td>-69291507082</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-2086718850</td>\n",
       "      <td>322655920</td>\n",
       "      <td>-1068880325</td>\n",
       "      <td>-515387047</td>\n",
       "      <td>13134290</td>\n",
       "      <td>-3335196012</td>\n",
       "      <td>-6784736202</td>\n",
       "      <td>-70775573636</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1973708660</td>\n",
       "      <td>362324550</td>\n",
       "      <td>-1062565920</td>\n",
       "      <td>-474016227</td>\n",
       "      <td>-16953120</td>\n",
       "      <td>-3164919377</td>\n",
       "      <td>-6730111117</td>\n",
       "      <td>-69205142171</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1926093600</td>\n",
       "      <td>546648740</td>\n",
       "      <td>-1003151875</td>\n",
       "      <td>-526656918</td>\n",
       "      <td>-16234440</td>\n",
       "      <td>-2925488093</td>\n",
       "      <td>-5998168873</td>\n",
       "      <td>-64856961559</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1928617740</td>\n",
       "      <td>520852410</td>\n",
       "      <td>-823056960</td>\n",
       "      <td>-576044196</td>\n",
       "      <td>-11012400</td>\n",
       "      <td>-2817878886</td>\n",
       "      <td>-6132398631</td>\n",
       "      <td>-63843781853</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1647135460</td>\n",
       "      <td>623191590</td>\n",
       "      <td>-798970600</td>\n",
       "      <td>-521068092</td>\n",
       "      <td>-23376885</td>\n",
       "      <td>-2367359447</td>\n",
       "      <td>-6114469357</td>\n",
       "      <td>-61308174591</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-1941797700</td>\n",
       "      <td>634052910</td>\n",
       "      <td>-860221635</td>\n",
       "      <td>-319491721</td>\n",
       "      <td>-4567780</td>\n",
       "      <td>-2492025926</td>\n",
       "      <td>-5786287321</td>\n",
       "      <td>-57379308013</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                  CU         AL          ZN         NI         PB  \\\n",
       "date       会员简称                                                            \n",
       "2018-10-08 中粮期货 -1883887680 -199593015  -449287560 -760855860    7669125   \n",
       "2018-10-09 中粮期货 -2021899060 -167662365 -1059156000 -737042165   33713685   \n",
       "2018-10-10 中粮期货 -2125892930 -223968095 -1355685090 -490269970   33540500   \n",
       "2018-10-11 中粮期货 -2230454720 -132418560 -1450356390 -613586480   72163140   \n",
       "2018-10-12 中粮期货 -2255304500 -158495060 -1553612500 -638110585  218937810   \n",
       "2018-10-15 中粮期货 -2145604505 -141344690 -1532937040 -532164926  185444480   \n",
       "2018-10-16 中粮期货 -2043577025  -10475220 -1215159920 -568863900  184583660   \n",
       "2018-10-17 中粮期货 -2052721360  -48122865 -1459126305 -546658416  183929600   \n",
       "2018-10-18 中粮期货 -2066710620  271584000 -1401753750 -472309734  181913655   \n",
       "2018-10-19 中粮期货 -2163462880  226911285 -1490882705 -529672056  212298200   \n",
       "2018-10-22 中粮期货 -2204748000  334010470 -1538727300 -506075490  196760850   \n",
       "2018-10-23 中粮期货 -2210414085  317452670 -1377154695 -497496132  122152565   \n",
       "2018-10-24 中粮期货 -2199454125  294166275 -1329446160 -527107698   13908465   \n",
       "2018-10-25 中粮期货 -2056621275  385550880 -1207138485 -572711229   13912385   \n",
       "2018-10-26 中粮期货 -2086718850  322655920 -1068880325 -515387047   13134290   \n",
       "2018-10-29 中粮期货 -1973708660  362324550 -1062565920 -474016227  -16953120   \n",
       "2018-10-30 中粮期货 -1926093600  546648740 -1003151875 -526656918  -16234440   \n",
       "2018-10-31 中粮期货 -1928617740  520852410  -823056960 -576044196  -11012400   \n",
       "2018-11-01 中粮期货 -1647135460  623191590  -798970600 -521068092  -23376885   \n",
       "2018-11-02 中粮期货 -1941797700  634052910  -860221635 -319491721   -4567780   \n",
       "\n",
       "variety                有色板块         工业品         商品板块 max min  \n",
       "date       会员简称                                               \n",
       "2018-10-08 中粮期货 -3285954990 -5477522010 -71044615790  PB  CU  \n",
       "2018-10-09 中粮期货 -3952045905 -5665513155 -76687351005  PB  CU  \n",
       "2018-10-10 中粮期货 -4162275585 -5921287420 -78571501110  PB  CU  \n",
       "2018-10-11 中粮期货 -4354653010 -5683207065 -76653224215  PB  CU  \n",
       "2018-10-12 中粮期货 -4386584835 -4841636035 -74116812685  PB  CU  \n",
       "2018-10-15 中粮期货 -4166606681 -4913318191 -72862043073  PB  CU  \n",
       "2018-10-16 中粮期货 -3653492405 -4920329935 -70711991125  PB  CU  \n",
       "2018-10-17 中粮期货 -3922699346 -5196281486 -71195885948  PB  CU  \n",
       "2018-10-18 中粮期货 -3487276449 -4987150599 -69060480607  AL  CU  \n",
       "2018-10-19 中粮期货 -3744808156 -5439907186 -71437517578  AL  CU  \n",
       "2018-10-22 中粮期货 -3718779470 -5176415720 -69276562220  AL  CU  \n",
       "2018-10-23 中粮期货 -3645459677 -6631575517 -73368642701  AL  CU  \n",
       "2018-10-24 中粮期货 -3747933243 -5917231358 -69645690044  AL  CU  \n",
       "2018-10-25 中粮期货 -3437007724 -6331086834 -69291507082  AL  CU  \n",
       "2018-10-26 中粮期货 -3335196012 -6784736202 -70775573636  AL  CU  \n",
       "2018-10-29 中粮期货 -3164919377 -6730111117 -69205142171  AL  CU  \n",
       "2018-10-30 中粮期货 -2925488093 -5998168873 -64856961559  AL  CU  \n",
       "2018-10-31 中粮期货 -2817878886 -6132398631 -63843781853  AL  CU  \n",
       "2018-11-01 中粮期货 -2367359447 -6114469357 -61308174591  AL  CU  \n",
       "2018-11-02 中粮期货 -2492025926 -5786287321 -57379308013  AL  CU  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "有色=sz.copy()\n",
    "有色=有色[['CU','AL','ZN','NI','PB','有色板块','工业品','商品板块']]\n",
    "有色['max']=有色[['CU','AL','ZN','NI','PB']].idxmax(axis=1) \n",
    "有色['min']=有色[['CU','AL','ZN','NI','PB']].idxmin(axis=1)\n",
    "有色"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>A</th>\n",
       "      <th>C</th>\n",
       "      <th>M</th>\n",
       "      <th>RM</th>\n",
       "      <th>Y</th>\n",
       "      <th>P</th>\n",
       "      <th>OI</th>\n",
       "      <th>CF</th>\n",
       "      <th>SR</th>\n",
       "      <th>JD</th>\n",
       "      <th>CS</th>\n",
       "      <th>AP</th>\n",
       "      <th>农产品</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-08</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-72135600</td>\n",
       "      <td>83068000</td>\n",
       "      <td>-10571216880</td>\n",
       "      <td>-473522700</td>\n",
       "      <td>-5884184600</td>\n",
       "      <td>-1187532320</td>\n",
       "      <td>-1927656600</td>\n",
       "      <td>-951577980</td>\n",
       "      <td>-1722631040</td>\n",
       "      <td>-12190970</td>\n",
       "      <td>-167657980</td>\n",
       "      <td>0</td>\n",
       "      <td>-22887238670</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-09</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-70988430</td>\n",
       "      <td>37812610</td>\n",
       "      <td>-11708944240</td>\n",
       "      <td>-465689670</td>\n",
       "      <td>-6037045200</td>\n",
       "      <td>-1222819850</td>\n",
       "      <td>-2113790800</td>\n",
       "      <td>-1339175145</td>\n",
       "      <td>-1889234360</td>\n",
       "      <td>-66094400</td>\n",
       "      <td>-167276100</td>\n",
       "      <td>0</td>\n",
       "      <td>-25043245585</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-10</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-72674730</td>\n",
       "      <td>-51712500</td>\n",
       "      <td>-12080507280</td>\n",
       "      <td>-452070060</td>\n",
       "      <td>-6191046800</td>\n",
       "      <td>-1267950530</td>\n",
       "      <td>-2088711440</td>\n",
       "      <td>-1281587500</td>\n",
       "      <td>-1781153640</td>\n",
       "      <td>-71527550</td>\n",
       "      <td>-183702480</td>\n",
       "      <td>0</td>\n",
       "      <td>-25522644510</td>\n",
       "      <td>AP</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-11</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-68888600</td>\n",
       "      <td>-95108780</td>\n",
       "      <td>-12293135260</td>\n",
       "      <td>-378339300</td>\n",
       "      <td>-5995848150</td>\n",
       "      <td>-1086998610</td>\n",
       "      <td>-2042354160</td>\n",
       "      <td>-1233188160</td>\n",
       "      <td>-1696852080</td>\n",
       "      <td>-12608490</td>\n",
       "      <td>-199487750</td>\n",
       "      <td>0</td>\n",
       "      <td>-25102809340</td>\n",
       "      <td>AP</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-12</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>15505520</td>\n",
       "      <td>-68229000</td>\n",
       "      <td>-11911564760</td>\n",
       "      <td>-389542250</td>\n",
       "      <td>-6183597280</td>\n",
       "      <td>-1153747160</td>\n",
       "      <td>-2120163920</td>\n",
       "      <td>-1045172750</td>\n",
       "      <td>-1769439700</td>\n",
       "      <td>-12648400</td>\n",
       "      <td>-265600550</td>\n",
       "      <td>0</td>\n",
       "      <td>-24904200250</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-15</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>-6687060</td>\n",
       "      <td>-11381516080</td>\n",
       "      <td>-380970780</td>\n",
       "      <td>-6172896560</td>\n",
       "      <td>-1173118240</td>\n",
       "      <td>-2118392760</td>\n",
       "      <td>-935667530</td>\n",
       "      <td>-1734385100</td>\n",
       "      <td>0</td>\n",
       "      <td>-264966000</td>\n",
       "      <td>0</td>\n",
       "      <td>-24168600110</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-16</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12867660</td>\n",
       "      <td>35551040</td>\n",
       "      <td>-10796805880</td>\n",
       "      <td>-348648300</td>\n",
       "      <td>-6140926260</td>\n",
       "      <td>-1182305280</td>\n",
       "      <td>-2098720680</td>\n",
       "      <td>-751912720</td>\n",
       "      <td>-1755072480</td>\n",
       "      <td>0</td>\n",
       "      <td>-250284850</td>\n",
       "      <td>0</td>\n",
       "      <td>-23276257750</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-17</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>13621900</td>\n",
       "      <td>59730440</td>\n",
       "      <td>-10618470030</td>\n",
       "      <td>-351293640</td>\n",
       "      <td>-6107730600</td>\n",
       "      <td>-1200838800</td>\n",
       "      <td>-2093566080</td>\n",
       "      <td>-813406155</td>\n",
       "      <td>-1730548340</td>\n",
       "      <td>0</td>\n",
       "      <td>-265743410</td>\n",
       "      <td>0</td>\n",
       "      <td>-23108244715</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-18</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12635220</td>\n",
       "      <td>124270560</td>\n",
       "      <td>-10528849040</td>\n",
       "      <td>-357126880</td>\n",
       "      <td>-5833562880</td>\n",
       "      <td>-1083398680</td>\n",
       "      <td>-2071118910</td>\n",
       "      <td>-661943565</td>\n",
       "      <td>-1898712080</td>\n",
       "      <td>0</td>\n",
       "      <td>-264251400</td>\n",
       "      <td>0</td>\n",
       "      <td>-22562057655</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-19</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12399260</td>\n",
       "      <td>-665700</td>\n",
       "      <td>-10415819100</td>\n",
       "      <td>-385646740</td>\n",
       "      <td>-5758712720</td>\n",
       "      <td>-885559950</td>\n",
       "      <td>-2083536160</td>\n",
       "      <td>-988136175</td>\n",
       "      <td>-2443698450</td>\n",
       "      <td>0</td>\n",
       "      <td>-253087500</td>\n",
       "      <td>0</td>\n",
       "      <td>-23202463235</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12099750</td>\n",
       "      <td>86175000</td>\n",
       "      <td>-9694635850</td>\n",
       "      <td>-356682270</td>\n",
       "      <td>-5943453090</td>\n",
       "      <td>-758963520</td>\n",
       "      <td>-2052467060</td>\n",
       "      <td>-973475405</td>\n",
       "      <td>-2624865200</td>\n",
       "      <td>0</td>\n",
       "      <td>-257804960</td>\n",
       "      <td>0</td>\n",
       "      <td>-22564072605</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>11994480</td>\n",
       "      <td>70904110</td>\n",
       "      <td>-9754537260</td>\n",
       "      <td>-348226500</td>\n",
       "      <td>-5908436730</td>\n",
       "      <td>-790305750</td>\n",
       "      <td>-1996948080</td>\n",
       "      <td>-1022210735</td>\n",
       "      <td>-2537430480</td>\n",
       "      <td>0</td>\n",
       "      <td>-261766680</td>\n",
       "      <td>0</td>\n",
       "      <td>-22536963625</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12421460</td>\n",
       "      <td>63951590</td>\n",
       "      <td>-9755929400</td>\n",
       "      <td>-344545070</td>\n",
       "      <td>-5577101200</td>\n",
       "      <td>-685301790</td>\n",
       "      <td>-1843272800</td>\n",
       "      <td>-1034152000</td>\n",
       "      <td>-2624658760</td>\n",
       "      <td>0</td>\n",
       "      <td>-256485560</td>\n",
       "      <td>0</td>\n",
       "      <td>-22045073530</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12052800</td>\n",
       "      <td>75244800</td>\n",
       "      <td>-9405500240</td>\n",
       "      <td>-343987350</td>\n",
       "      <td>-5374232960</td>\n",
       "      <td>-862337280</td>\n",
       "      <td>-1757536500</td>\n",
       "      <td>-663318000</td>\n",
       "      <td>-2674602720</td>\n",
       "      <td>0</td>\n",
       "      <td>-289527390</td>\n",
       "      <td>0</td>\n",
       "      <td>-21283744840</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>11564620</td>\n",
       "      <td>59963760</td>\n",
       "      <td>-9436826540</td>\n",
       "      <td>-341063870</td>\n",
       "      <td>-5312536810</td>\n",
       "      <td>-1034237620</td>\n",
       "      <td>-1597992000</td>\n",
       "      <td>-639846720</td>\n",
       "      <td>-2524035840</td>\n",
       "      <td>0</td>\n",
       "      <td>-296725020</td>\n",
       "      <td>-296202360</td>\n",
       "      <td>-21407938400</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>72290240</td>\n",
       "      <td>-8626999920</td>\n",
       "      <td>-352299920</td>\n",
       "      <td>-5374043100</td>\n",
       "      <td>-974394480</td>\n",
       "      <td>-1642553280</td>\n",
       "      <td>-917665600</td>\n",
       "      <td>-2262938880</td>\n",
       "      <td>0</td>\n",
       "      <td>-295439270</td>\n",
       "      <td>-301965300</td>\n",
       "      <td>-20676009510</td>\n",
       "      <td>C</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>96400150</td>\n",
       "      <td>-19197990</td>\n",
       "      <td>-7706580050</td>\n",
       "      <td>-338521740</td>\n",
       "      <td>-5360676200</td>\n",
       "      <td>-913192380</td>\n",
       "      <td>-1652571600</td>\n",
       "      <td>-897528720</td>\n",
       "      <td>-2230009600</td>\n",
       "      <td>0</td>\n",
       "      <td>-302402650</td>\n",
       "      <td>-310553670</td>\n",
       "      <td>-19634834450</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>11601660</td>\n",
       "      <td>-136817700</td>\n",
       "      <td>-7524338880</td>\n",
       "      <td>-353584080</td>\n",
       "      <td>-5045313520</td>\n",
       "      <td>-912230810</td>\n",
       "      <td>-1640930320</td>\n",
       "      <td>-863827335</td>\n",
       "      <td>-2197335000</td>\n",
       "      <td>0</td>\n",
       "      <td>-261954460</td>\n",
       "      <td>-314625840</td>\n",
       "      <td>-19239356285</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>12512500</td>\n",
       "      <td>-79563060</td>\n",
       "      <td>-6842978400</td>\n",
       "      <td>-322187590</td>\n",
       "      <td>-4998007080</td>\n",
       "      <td>-931916960</td>\n",
       "      <td>-1624006920</td>\n",
       "      <td>-864515520</td>\n",
       "      <td>-1894280960</td>\n",
       "      <td>0</td>\n",
       "      <td>-264880000</td>\n",
       "      <td>-342070090</td>\n",
       "      <td>-18151894080</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>0</td>\n",
       "      <td>-213110600</td>\n",
       "      <td>-6165892350</td>\n",
       "      <td>-468284250</td>\n",
       "      <td>-4442643560</td>\n",
       "      <td>-900821200</td>\n",
       "      <td>-1494827270</td>\n",
       "      <td>-1032589880</td>\n",
       "      <td>-1684731960</td>\n",
       "      <td>0</td>\n",
       "      <td>-241650360</td>\n",
       "      <td>-352204480</td>\n",
       "      <td>-16996755910</td>\n",
       "      <td>A</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                 A          C            M         RM           Y  \\\n",
       "date       会员简称                                                            \n",
       "2018-10-08 中粮期货 -72135600   83068000 -10571216880 -473522700 -5884184600   \n",
       "2018-10-09 中粮期货 -70988430   37812610 -11708944240 -465689670 -6037045200   \n",
       "2018-10-10 中粮期货 -72674730  -51712500 -12080507280 -452070060 -6191046800   \n",
       "2018-10-11 中粮期货 -68888600  -95108780 -12293135260 -378339300 -5995848150   \n",
       "2018-10-12 中粮期货  15505520  -68229000 -11911564760 -389542250 -6183597280   \n",
       "2018-10-15 中粮期货         0   -6687060 -11381516080 -380970780 -6172896560   \n",
       "2018-10-16 中粮期货  12867660   35551040 -10796805880 -348648300 -6140926260   \n",
       "2018-10-17 中粮期货  13621900   59730440 -10618470030 -351293640 -6107730600   \n",
       "2018-10-18 中粮期货  12635220  124270560 -10528849040 -357126880 -5833562880   \n",
       "2018-10-19 中粮期货  12399260    -665700 -10415819100 -385646740 -5758712720   \n",
       "2018-10-22 中粮期货  12099750   86175000  -9694635850 -356682270 -5943453090   \n",
       "2018-10-23 中粮期货  11994480   70904110  -9754537260 -348226500 -5908436730   \n",
       "2018-10-24 中粮期货  12421460   63951590  -9755929400 -344545070 -5577101200   \n",
       "2018-10-25 中粮期货  12052800   75244800  -9405500240 -343987350 -5374232960   \n",
       "2018-10-26 中粮期货  11564620   59963760  -9436826540 -341063870 -5312536810   \n",
       "2018-10-29 中粮期货         0   72290240  -8626999920 -352299920 -5374043100   \n",
       "2018-10-30 中粮期货  96400150  -19197990  -7706580050 -338521740 -5360676200   \n",
       "2018-10-31 中粮期货  11601660 -136817700  -7524338880 -353584080 -5045313520   \n",
       "2018-11-01 中粮期货  12512500  -79563060  -6842978400 -322187590 -4998007080   \n",
       "2018-11-02 中粮期货         0 -213110600  -6165892350 -468284250 -4442643560   \n",
       "\n",
       "variety                   P          OI          CF          SR        JD  \\\n",
       "date       会员简称                                                             \n",
       "2018-10-08 中粮期货 -1187532320 -1927656600  -951577980 -1722631040 -12190970   \n",
       "2018-10-09 中粮期货 -1222819850 -2113790800 -1339175145 -1889234360 -66094400   \n",
       "2018-10-10 中粮期货 -1267950530 -2088711440 -1281587500 -1781153640 -71527550   \n",
       "2018-10-11 中粮期货 -1086998610 -2042354160 -1233188160 -1696852080 -12608490   \n",
       "2018-10-12 中粮期货 -1153747160 -2120163920 -1045172750 -1769439700 -12648400   \n",
       "2018-10-15 中粮期货 -1173118240 -2118392760  -935667530 -1734385100         0   \n",
       "2018-10-16 中粮期货 -1182305280 -2098720680  -751912720 -1755072480         0   \n",
       "2018-10-17 中粮期货 -1200838800 -2093566080  -813406155 -1730548340         0   \n",
       "2018-10-18 中粮期货 -1083398680 -2071118910  -661943565 -1898712080         0   \n",
       "2018-10-19 中粮期货  -885559950 -2083536160  -988136175 -2443698450         0   \n",
       "2018-10-22 中粮期货  -758963520 -2052467060  -973475405 -2624865200         0   \n",
       "2018-10-23 中粮期货  -790305750 -1996948080 -1022210735 -2537430480         0   \n",
       "2018-10-24 中粮期货  -685301790 -1843272800 -1034152000 -2624658760         0   \n",
       "2018-10-25 中粮期货  -862337280 -1757536500  -663318000 -2674602720         0   \n",
       "2018-10-26 中粮期货 -1034237620 -1597992000  -639846720 -2524035840         0   \n",
       "2018-10-29 中粮期货  -974394480 -1642553280  -917665600 -2262938880         0   \n",
       "2018-10-30 中粮期货  -913192380 -1652571600  -897528720 -2230009600         0   \n",
       "2018-10-31 中粮期货  -912230810 -1640930320  -863827335 -2197335000         0   \n",
       "2018-11-01 中粮期货  -931916960 -1624006920  -864515520 -1894280960         0   \n",
       "2018-11-02 中粮期货  -900821200 -1494827270 -1032589880 -1684731960         0   \n",
       "\n",
       "variety                 CS         AP          农产品 max min  \n",
       "date       会员简称                                             \n",
       "2018-10-08 中粮期货 -167657980          0 -22887238670   C   M  \n",
       "2018-10-09 中粮期货 -167276100          0 -25043245585   C   M  \n",
       "2018-10-10 中粮期货 -183702480          0 -25522644510  AP   M  \n",
       "2018-10-11 中粮期货 -199487750          0 -25102809340  AP   M  \n",
       "2018-10-12 中粮期货 -265600550          0 -24904200250   A   M  \n",
       "2018-10-15 中粮期货 -264966000          0 -24168600110   A   M  \n",
       "2018-10-16 中粮期货 -250284850          0 -23276257750   C   M  \n",
       "2018-10-17 中粮期货 -265743410          0 -23108244715   C   M  \n",
       "2018-10-18 中粮期货 -264251400          0 -22562057655   C   M  \n",
       "2018-10-19 中粮期货 -253087500          0 -23202463235   A   M  \n",
       "2018-10-22 中粮期货 -257804960          0 -22564072605   C   M  \n",
       "2018-10-23 中粮期货 -261766680          0 -22536963625   C   M  \n",
       "2018-10-24 中粮期货 -256485560          0 -22045073530   C   M  \n",
       "2018-10-25 中粮期货 -289527390          0 -21283744840   C   M  \n",
       "2018-10-26 中粮期货 -296725020 -296202360 -21407938400   C   M  \n",
       "2018-10-29 中粮期货 -295439270 -301965300 -20676009510   C   M  \n",
       "2018-10-30 中粮期货 -302402650 -310553670 -19634834450   A   M  \n",
       "2018-10-31 中粮期货 -261954460 -314625840 -19239356285   A   M  \n",
       "2018-11-01 中粮期货 -264880000 -342070090 -18151894080   A   M  \n",
       "2018-11-02 中粮期货 -241650360 -352204480 -16996755910   A   M  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "农产品=sz.copy()\n",
    "农产品=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP','农产品']]\n",
    "农产品['max']=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].idxmax(axis=1) \n",
    "农产品['min']=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].idxmin(axis=1)\n",
    "农产品"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>化工板块</th>\n",
       "      <th>黑色板块</th>\n",
       "      <th>有色板块</th>\n",
       "      <th>农产品</th>\n",
       "      <th>油脂板块</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-10-10</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-78571501110</td>\n",
       "      <td>-5921287420</td>\n",
       "      <td>-951243585</td>\n",
       "      <td>-724674150</td>\n",
       "      <td>-4162275585</td>\n",
       "      <td>-25522644510</td>\n",
       "      <td>-9547708770</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-11</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-76653224215</td>\n",
       "      <td>-5683207065</td>\n",
       "      <td>-679219925</td>\n",
       "      <td>-593265970</td>\n",
       "      <td>-4354653010</td>\n",
       "      <td>-25102809340</td>\n",
       "      <td>-9125200920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-12</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-74116812685</td>\n",
       "      <td>-4841636035</td>\n",
       "      <td>-604232840</td>\n",
       "      <td>158426760</td>\n",
       "      <td>-4386584835</td>\n",
       "      <td>-24904200250</td>\n",
       "      <td>-9457508360</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-15</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-72862043073</td>\n",
       "      <td>-4913318191</td>\n",
       "      <td>-763466430</td>\n",
       "      <td>34252200</td>\n",
       "      <td>-4166606681</td>\n",
       "      <td>-24168600110</td>\n",
       "      <td>-9464407560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-16</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-70711991125</td>\n",
       "      <td>-4920329935</td>\n",
       "      <td>-982112910</td>\n",
       "      <td>-255086940</td>\n",
       "      <td>-3653492405</td>\n",
       "      <td>-23276257750</td>\n",
       "      <td>-9421952220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-17</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-71195885948</td>\n",
       "      <td>-5196281486</td>\n",
       "      <td>-976528180</td>\n",
       "      <td>-276637640</td>\n",
       "      <td>-3922699346</td>\n",
       "      <td>-23108244715</td>\n",
       "      <td>-9402135480</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-18</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-69060480607</td>\n",
       "      <td>-4987150599</td>\n",
       "      <td>-1045253940</td>\n",
       "      <td>-434311740</td>\n",
       "      <td>-3487276449</td>\n",
       "      <td>-22562057655</td>\n",
       "      <td>-8988080470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-19</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-71437517578</td>\n",
       "      <td>-5439907186</td>\n",
       "      <td>-1150000650</td>\n",
       "      <td>-522498900</td>\n",
       "      <td>-3744808156</td>\n",
       "      <td>-23202463235</td>\n",
       "      <td>-8727808830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-22</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-69276562220</td>\n",
       "      <td>-5176415720</td>\n",
       "      <td>-1093355680</td>\n",
       "      <td>-383095750</td>\n",
       "      <td>-3718779470</td>\n",
       "      <td>-22564072605</td>\n",
       "      <td>-8754883670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-23</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-73368642701</td>\n",
       "      <td>-6631575517</td>\n",
       "      <td>-1156844120</td>\n",
       "      <td>-1805631060</td>\n",
       "      <td>-3645459677</td>\n",
       "      <td>-22536963625</td>\n",
       "      <td>-8695690560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-24</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-69645690044</td>\n",
       "      <td>-5917231358</td>\n",
       "      <td>-759682765</td>\n",
       "      <td>-1377037990</td>\n",
       "      <td>-3747933243</td>\n",
       "      <td>-22045073530</td>\n",
       "      <td>-8105675790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-25</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-69291507082</td>\n",
       "      <td>-6331086834</td>\n",
       "      <td>-1240675210</td>\n",
       "      <td>-1637374300</td>\n",
       "      <td>-3437007724</td>\n",
       "      <td>-21283744840</td>\n",
       "      <td>-7994106740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-26</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-70775573636</td>\n",
       "      <td>-6784736202</td>\n",
       "      <td>-1326669750</td>\n",
       "      <td>-2084706920</td>\n",
       "      <td>-3335196012</td>\n",
       "      <td>-21407938400</td>\n",
       "      <td>-7944766430</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-29</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-69205142171</td>\n",
       "      <td>-6730111117</td>\n",
       "      <td>-1103186240</td>\n",
       "      <td>-2427293660</td>\n",
       "      <td>-3164919377</td>\n",
       "      <td>-20676009510</td>\n",
       "      <td>-7990990860</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-30</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-64856961559</td>\n",
       "      <td>-5998168873</td>\n",
       "      <td>-589936060</td>\n",
       "      <td>-2440344740</td>\n",
       "      <td>-2925488093</td>\n",
       "      <td>-19634834450</td>\n",
       "      <td>-7926440180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-31</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-63843781853</td>\n",
       "      <td>-6132398631</td>\n",
       "      <td>-764342185</td>\n",
       "      <td>-2515570400</td>\n",
       "      <td>-2817878886</td>\n",
       "      <td>-19239356285</td>\n",
       "      <td>-7598474650</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-61308174591</td>\n",
       "      <td>-6114469357</td>\n",
       "      <td>-586506110</td>\n",
       "      <td>-3029671500</td>\n",
       "      <td>-2367359447</td>\n",
       "      <td>-18151894080</td>\n",
       "      <td>-7553930960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-02</th>\n",
       "      <th>中粮期货</th>\n",
       "      <td>-57379308013</td>\n",
       "      <td>-5786287321</td>\n",
       "      <td>-662212935</td>\n",
       "      <td>-2554961660</td>\n",
       "      <td>-2492025926</td>\n",
       "      <td>-16996755910</td>\n",
       "      <td>-6838292030</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                 商品板块         工业品        化工板块        黑色板块        有色板块  \\\n",
       "date       会员简称                                                                \n",
       "2018-10-10 中粮期货 -78571501110 -5921287420  -951243585  -724674150 -4162275585   \n",
       "2018-10-11 中粮期货 -76653224215 -5683207065  -679219925  -593265970 -4354653010   \n",
       "2018-10-12 中粮期货 -74116812685 -4841636035  -604232840   158426760 -4386584835   \n",
       "2018-10-15 中粮期货 -72862043073 -4913318191  -763466430    34252200 -4166606681   \n",
       "2018-10-16 中粮期货 -70711991125 -4920329935  -982112910  -255086940 -3653492405   \n",
       "2018-10-17 中粮期货 -71195885948 -5196281486  -976528180  -276637640 -3922699346   \n",
       "2018-10-18 中粮期货 -69060480607 -4987150599 -1045253940  -434311740 -3487276449   \n",
       "2018-10-19 中粮期货 -71437517578 -5439907186 -1150000650  -522498900 -3744808156   \n",
       "2018-10-22 中粮期货 -69276562220 -5176415720 -1093355680  -383095750 -3718779470   \n",
       "2018-10-23 中粮期货 -73368642701 -6631575517 -1156844120 -1805631060 -3645459677   \n",
       "2018-10-24 中粮期货 -69645690044 -5917231358  -759682765 -1377037990 -3747933243   \n",
       "2018-10-25 中粮期货 -69291507082 -6331086834 -1240675210 -1637374300 -3437007724   \n",
       "2018-10-26 中粮期货 -70775573636 -6784736202 -1326669750 -2084706920 -3335196012   \n",
       "2018-10-29 中粮期货 -69205142171 -6730111117 -1103186240 -2427293660 -3164919377   \n",
       "2018-10-30 中粮期货 -64856961559 -5998168873  -589936060 -2440344740 -2925488093   \n",
       "2018-10-31 中粮期货 -63843781853 -6132398631  -764342185 -2515570400 -2817878886   \n",
       "2018-11-01 中粮期货 -61308174591 -6114469357  -586506110 -3029671500 -2367359447   \n",
       "2018-11-02 中粮期货 -57379308013 -5786287321  -662212935 -2554961660 -2492025926   \n",
       "\n",
       "variety                  农产品        油脂板块  \n",
       "date       会员简称                           \n",
       "2018-10-10 中粮期货 -25522644510 -9547708770  \n",
       "2018-10-11 中粮期货 -25102809340 -9125200920  \n",
       "2018-10-12 中粮期货 -24904200250 -9457508360  \n",
       "2018-10-15 中粮期货 -24168600110 -9464407560  \n",
       "2018-10-16 中粮期货 -23276257750 -9421952220  \n",
       "2018-10-17 中粮期货 -23108244715 -9402135480  \n",
       "2018-10-18 中粮期货 -22562057655 -8988080470  \n",
       "2018-10-19 中粮期货 -23202463235 -8727808830  \n",
       "2018-10-22 中粮期货 -22564072605 -8754883670  \n",
       "2018-10-23 中粮期货 -22536963625 -8695690560  \n",
       "2018-10-24 中粮期货 -22045073530 -8105675790  \n",
       "2018-10-25 中粮期货 -21283744840 -7994106740  \n",
       "2018-10-26 中粮期货 -21407938400 -7944766430  \n",
       "2018-10-29 中粮期货 -20676009510 -7990990860  \n",
       "2018-10-30 中粮期货 -19634834450 -7926440180  \n",
       "2018-10-31 中粮期货 -19239356285 -7598474650  \n",
       "2018-11-01 中粮期货 -18151894080 -7553930960  \n",
       "2018-11-02 中粮期货 -16996755910 -6838292030  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "板块=sz.copy()\n",
    "板块=板块[['商品板块','工业品','化工板块','黑色板块','有色板块','农产品','油脂板块']]\n",
    "板块['2018-10-1':]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
